package routers

import (
	beego "github.com/beego/beego/v2/server/web"
	"github.com/beego/beego/v2/server/web/filter/cors"
	"user-mgr/controllers"
)

func init() {
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins:  true,
		AllowCredentials: true,
		AllowOrigins:     []string{"*"},
		AllowMethods:     []string{"*"},
		AllowHeaders:     []string{"*"},
		ExposeHeaders:    []string{"*"},
		MaxAge:           0,
	}))
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.UserController{}, "post:Login")
	beego.Router("/doneAdd", &controllers.UserController{}, "post:DoneAdd")
	beego.Router("/roleList", &controllers.UserController{}, "get:RoleList")
	beego.Router("/doneList", &controllers.UserController{}, "get:DoneList")
	beego.Router("roleAdd", &controllers.UserController{}, "post:RoleAdd")
	beego.Router("/userAdd", &controllers.UserController{}, "post:UserAdd")
	beego.Router("/userList", &controllers.UserController{}, "get:UserList")
	beego.Router("/userDel", &controllers.UserController{}, "get:UserDel")
	beego.Router("/userShow", &controllers.UserController{}, "post:UserShow")
}
